import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
import Loans from '../views/Loans.vue'
//使用懒加载
const Invest = () => import('../views/Invest.vue')
const Fun = () => import('../views/Fun.vue')
const Music = () => import('../views/Music.vue')
const Random = () => import('../views/Random.vue')
const RandomImg = () => import('../views/RandomImg.vue')
const Encryption = () => import('../views/Encryption.vue')
const Stock = () => import('../views/Stock.vue')
const Mathematics = () => import('../views/Mathematics.vue')
const ChangeCode = () => import('../views/ChangeCode.vue')
const TextTool = () => import('../views/TextTool.vue')
const StockCost = () => import('../views/StockCost.vue')
const Test = () => import('../views/Test.vue')

Vue.use(VueRouter)

const routes = [{
	path: '/',
	component: Index,
	children: [ //通过children配置子级路由
		{
			path: '', //默认值
			component: Loans
		},
		{
			path: '/Invest',
			component: Invest
		},
		{
			path: '/Fun',
			component: Fun
		},
		{
			path: '/Music',
			component: Music
		},
		{
			path: '/Random',
			component: Random
		},
		{
			path: '/RandomImg',
			component: RandomImg
		},
		{
			path: '/Encryption',
			component: Encryption
		},
		{
			path: '/Stock',
			component: Stock
		},
		{
			path: '/Mathematics',
			component: Mathematics
		},
		{
			path: '/ChangeCode',
			component: ChangeCode
		},
		{
			path: '/TextTool',
			component: TextTool
		},
		{
			path: '/StockCost',
			component: StockCost
		},
		{
			path: '/Test',
			component: Test
		}
	],
}]

const router = new VueRouter({
	mode: 'history', //改为history模式
	routes
})

export default router
